import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: "/index",
  },
  {
    path: '/index',
    component: () => import('@/views/index/index.vue'),
    meta: {
      name: "招才引智",
      title: "首页",
    },
  },
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      name: "招才引智",
      title: "首页",
    },
  },
  {
    path: '/apply',
    component: () => import('@/views/apply/index.vue'),
    meta: {
      name: "招才引智",
      title: "首页",
    },
  },
  {
    path: '/applyComp',
    component: () => import('@/views/applyComp/applyComp.vue'),
    meta: {
      name: "招才引智",
      title: "首页",
    },
  },
  {
    path: '/detailsPage',
    component: () => import('@/views/detailsPage/detailsPage.vue'),
    meta: {
      name: "招才引智",
      title: "首页",
    },
  },
  {
    path: "/userAgreement",
    component: () => import("@/views/userAgreement/userAgreement.vue"),
    meta: {
      name: "用户协议",
    },
  },
  {
    path: "/privateAgreement",
    component: () => import("@/views/privateAgreement/privateAgreement.vue"),
    meta: {
      name: "隐私协议",
    },
  },
  
  {
		path: "/pageNotFound",
		name: "pageNotFound",
		component: () => import("@/views/page-not-found/pagenotfound.vue"),
	},
	{
		path: "*",
		redirect: "/pageNotFound",
		name: "notFound",
		hidden: true,
	},
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, savedPosition) {
		if (savedPosition) {
			return savedPosition;
		} else {
			return {
				x: 0,
				y: 0,
			};
		}
	},
})

const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return routerPush.call(this, location).catch((error) => error);
};

export default router